<template>
  <div class="about">
    <h1>登录</h1>
    <input type="text" />
    <input type="text" />
    <input type="button" @click="getLoginData" value="submit" />
  </div>
</template>
<script>
import axios from 'axios';
export default {
  data () {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    // 跨域： 服务端解决 代理解决
    async getLoginData() {
     let data = await axios.post('/api/login', {
        username: this.username,
        password: this.password
      })
      // 存储 异步
      // session
      if (data.data.code ===0) {
        sessionStorage.setItem('token', data.data.token)
      }
      console.log(data, 'data')
    }
  },
}
</script>
